import {Image, View, Text, Swiper, SwiperItem} from '@tarojs/components';
import React, {Component} from 'react';
import {AtIcon} from 'taro-ui';

import Taro, {getCurrentInstance} from '@tarojs/taro';
import {connect} from 'react-redux';
import './index.less';
import * as T from './types';
import actions from './actions';
import {store2Props} from './selectors';
import 'taro-ui/dist/style/components/icon.scss';
import icon6 from '@/assets/image/order/icon_6.png';

import api from 'api';
actions().actions.loadReducer();
// @ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class Index extends Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {
      list: [
        // {
        //   label: '美团订单',
        //   url: '/pages/package-D/meituanOrders/index',
        // },
        {
          label: '回收订单',
          url: '/pages/package-D/equityOrders/index',
        },
        {
          label: '蚂蚁星球订单',
          url: '/pages/package-D/cinemaTicketOrder/index',
        },
        {
          label: '快递订单',
          url: 'pages/mine/orders?mailId=119949666877440',
          image: icon6,
        },
      ],
    };
  }

  render() {
    return (
      <View className="packageDOrderRamp">
        {this.state.list.map((e, i) => (
          <View
            key={i}
            className="packageDOrderRampItem"
            onClick={() => {
              if (e.label == '美团订单') {
                Taro.navigateToMiniProgram({
                  appId: 'wxde8ac0a21135c07d',
                  path: e.url,
                  extraData: {
                    foo: 'bar',
                  },
                  envVersion: 'release',
                  success: function (res) {
                    // 打开成功
                  },
                });
              } else if (e.label == '快递订单') {
                Taro.navigateToMiniProgram({
                  appId: 'wxf772255062165d94',
                  path: e.url,
                  envVersion: 'release',
                  success: function (res) {
                    // 打开成功
                  },
                });
              } else {
                Taro.navigateTo({url: e.url});
              }
            }}
          >
            <View className="row">
              <View>
                <Image className="logo" src={e.image} mode="widthFix" />
              </View>
              {e.label}
            </View>
            <AtIcon
              onClick={() => {
                Taro.navigateBack();
              }}
              customStyle={{zIndex: 2}}
              value="chevron-right"
              size="24"
              color="#BFBFBF"
            ></AtIcon>
          </View>
        ))}
      </View>
    );
  }
}
